<div class="widget-box dataTables_wrapper ">
	<?php $form=$this->beginWidget('CActiveForm', array(
			'id'=>'products-form',
			'action' => Yii::app()->createUrl('/products/ManageProductImages/admin', array('product_id'=>$_GET['product_id'])),
			'htmlOptions'=>array(
					'class'=>'jform',
			),

	)); ?>
	
	<?php
		$this->widget('ext.selgridview.SelGridView', array(
			'id' => 'products-image-grid',
			'dataProvider' => $model->search(),
			//'filter' => $model,
			'template' => count($model->search()->getData())==0?'{items}':'{items}<div class="fg-toolbar widget-content"><a class="btn" href="#" onclick="return actionDelete();">Delete</a>{pager}{summary}</div>',
			'selectableRows'=>count($model->search()->getData()),
			'itemsCssClass'=>'table table-bordered table-striped table-hover table-border-bottom',
			'summaryCssClass'=>'summary widget-title',
			'cssFile'=> Yii::app()->request->baseUrl.WWWROOT_BACKEND."/css/gridview/styles.css",
			'htmlOptions'=>array('class'=>'widget-content nopadding grid-view'),

			//'baseScriptUrl'	=>	"", 
			'columns' => array(
				array(
					'class' => 'CCheckBoxColumn',
					'htmlOptions' => array('class'=>'jform'),
					'headerHtmlOptions' => array('class' => 'jform jlb_checkbox_check_all jlb_checkbox_check_all_disable'),
					'header' => '<input type="checkbox" class="select-on-check-all"/>',
					'value' => '$data->primaryKey',
				),
				//'id',
				'name',
				//'alias',
				//'image',
				array(
					'name' => 'image',
					'type' => 'image',
					'htmlOptions'=>array('style'=> 'max-width: 133px; max-height: 100px'),
					'value' => 'Yii::app()->createUrl("/").Yii::app()->controller->module->product_image["url"].$data->image',
					//'type'=>'raw',
					//'value'=> //'CHtml::image(Yii::app()->createUrl("/").Yii::app()->controller->module->product_image["url"].$data->image,"alt", array("style"=>"max-width: 133px; max-height: 100px"))',
				),
				'priority',
				'created',
				/*
				'description',
				'content',
				'priority',
				'created',
				'modified',
				*/
				array(
							'name' => 'is_published',
							'value' => '($data->is_published === 0) ? Yii::t(\'app\', \'No\') : Yii::t(\'app\', \'Yes\')',
							'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),
				),
				array(
						'class' => 'CButtonColumn',
						'htmlOptions' => array('class'=>null),
						'header' => 'Options',
						'headerHtmlOptions' => array('class'=>null),
				),
			),
		));
	?>
	
	<div class='fg-toolbar ui-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix'>
		<a href="<?php echo Yii::app()->createUrl("/products/manageUpload", array('product_id'=>$_GET['product_id'])); ?>", class='btn btn-inverse'>Multi upload images</a>
		<a href="<?php echo Yii::app()->createUrl("/products/ManageProductImages/create/product_id/".$_GET['product_id']); ?>" class='btn btn-inverse'>Upload an image</a>
	</div>
	
    <?php $this->endWidget(); ?>
</div>
<script type="text/javascript">
/*
    $(document).ready(function(){
        $('.jqTransform').jqTransform();
				$(".jlb_checkbox_check_all .jqTransformCheckbox").jlb_checkbox_check_all(); 
    });
		//$(".jform").jqTransform();
*/
	function actionDelete()
	{	
		if ($("input:checkbox[name='products-image-grid_c0[]']:checked").length == 0) {
			alert('<?php echo 'Please select at least one item to remove.'; ?>');
			return false;
		}
		if (confirm('<?php echo 'Are you sure you want to delete?'; ?>')) $('#products-form').submit();
		return false;
	}
</script>